#!/usr/bin/python
# encoding:utf-8
import RPi.GPIO as GPIO
import time
import rospy


if __name__ == "__main__":
    pin_fire=4
    print(pin_fire)
    GPIO.setmode(GPIO.BCM)
    GPIO.setup(pin_fire, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)    
    try:
        while True:
            status = GPIO.input(pin_fire)
            if status == True:
                print('smoke:0')
                rospy.set_param("smokeExist",0)
            else:
                print('smoke:1')
                rospy.set_param("smokeExist",1)
            time.sleep(0.5)
    except KeyboradInterrupt:
        GPIO.cleanup()